package com.uchiha.nova.mainService.wrapper;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.uchiha.nova.core.model.entity.VisitorApplyInfoEntity;
import com.uchiha.nova.core.model.vo.VisitorApplyInfoVO;
import com.uchiha.nova.core.tool.support.BaseEntityWrapper;
import com.uchiha.nova.core.tool.util.SpringUtil;
import com.uchiha.nova.mainService.service.IVisitorApplyInfoService;

import java.util.List;
import java.util.stream.Collectors;
/**
 * 访问信息 包装类,返回视图层所需的字段
 *
 * @author Uchihashiamu
 */
public class VisitorApplyInfoWrapper extends BaseEntityWrapper<VisitorApplyInfoEntity, VisitorApplyInfoVO>  {
  
  IVisitorApplyInfoService visitorApplyInfoService = SpringUtil.getBean(IVisitorApplyInfoService.class);
  
	public static VisitorApplyInfoWrapper build() {
		return new VisitorApplyInfoWrapper();
 	}

	@Override
	public VisitorApplyInfoVO entityVO(VisitorApplyInfoEntity visitorApplyInfoEntity) {
		VisitorApplyInfoVO visitorApplyInfoVO = new VisitorApplyInfoVO();
		BeanUtil.copyProperties(visitorApplyInfoEntity, visitorApplyInfoVO);

		return visitorApplyInfoVO;
	}
	public List<VisitorApplyInfoVO> listVO(List<VisitorApplyInfoEntity> list) {
		List<VisitorApplyInfoVO> collect = list.stream().map(item -> {
            VisitorApplyInfoVO visitorApplyInfoVO = new VisitorApplyInfoVO();
		    BeanUtil.copyProperties(item, visitorApplyInfoVO);			
			return visitorApplyInfoVO;
		}).collect(Collectors.toList());
		return collect;
    // return ForestNodeMerger.merge(collect);
	}
  
  	@Override
	public IPage<VisitorApplyInfoVO> pageVO(IPage<VisitorApplyInfoEntity> pages) {
		IPage<VisitorApplyInfoVO> page = pages.convert(item->{
            VisitorApplyInfoVO visitorApplyInfoVO = new VisitorApplyInfoVO();
		    BeanUtil.copyProperties(item, visitorApplyInfoVO);			
			return visitorApplyInfoVO;
		});
		return page;
	}
}
